<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="uct" uri="/WEB-INF/uct.tld" %>
<%@ taglib prefix="portal" uri="/WEB-INF/portal.tld" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/sale/include/common-base.jsp"%>
  <script src="${ctx}/js/funds.js"></script>
  <script src="${ctx}/js/star-rating.js"></script>
  <script src="${ctx}/js/jquery-md5-min.js"></script>
  <script src="${ctx}/js/jquery-tools.min.js"></script>

  <title>发售交易会员中心</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>
<body class="hold-transition ${sysUserColor} sidebar-mini">
<div class="wrapper">
<!-- top start -->
  <%@include file="/common/sale/top-user.jsp" %>
<!-- top end -->
<!-- left start -->
  <%@include file="/common/sale/left-user.jsp" %>
<!-- left end-->
 <!-- main start -->
  <div class="content-wrapper">
	  <div class="content">

		<!-- 账户信息 -->
	    <div class="box box-solid">
		   <div class="box-body">
			  <div class="col-lg-12 pt10">
				  <div class="col-lg-6">

					  <div class="col-lg-3 text-center">
						 <p class="user_tx">
							 <img id="picUrl" src="${ctx}/images/user/person2.png" class="img-circle picUrl" style="width:100px;height:100px;" />
						</p>
					  </div>

					  <div class="col-lg-9 lh25" >
								<p class="text-small">
									<span>会员账号：</span>${loginUser.userEname} | ${loginUser.userCname}
								</p>
								<p class="text-small">
									<span>会员状态：</span>
									<c:if test="${'1'==loginUser.userStatus}">正常</c:if>
									<c:if test="${'0'==loginUser.userStatus}">停用</c:if>
								</p>
								<p class="text-small">
									<span>会员信用：</span>
									<input id="userLevel" value="${loginUser.user.userLevel}" type="number" class="rating" min=0 max=10 step=1 data-size="xs">
								</p>
								<p class="text-small">
									<span>手机号码：</span>
									<c:if test="${empty loginUser.mobile}"><span style="color:red;">未绑定</span></c:if>
									<c:if test="${!empty loginUser.mobile}">${loginUser.mobile}</c:if>
								</p>
						  </div>
					  </div>

					  <div class="col-lg-6 lh25">
						  <div class="col-lg-4 bor_r">
							<p>总资金</p>
							<h5><i class="fa fa-yen"></i><span id="fundsAmtTotal">0</span></h5>
						  </div>
						  <div class="col-lg-4 bor_r">
							<p>可用资金</p>
							<h5 class="color_green"><i class="fa fa-yen"></i><span id="fundsM1">0</span></h5>
						  </div>
						  <div class="col-lg-4">
							<p>冻结资金</p>
							<h5 class="color_blue"><i class="fa fa-yen"></i><span id="fundsM2">0</span></h5>
						  </div>

						  <div class="col-lg-12 money_btn">
							<div id="funds_1" style="display:none;">
								<button class="btn btn-danger f14 ov" onclick="showFundsWin()"> <i class="fa fa-bank f12"></i> &nbsp;钱包开户&nbsp; </button>
								<P style="padding-top:10px;">您还未开通资金钱包账户，请先开通。</P>
							</div>
							<div id="funds_2" style="display:none;">
								<button class="btn btn-danger f14" onclick="toFunds('in')"> <i class="fa fa-sign-in f12"></i> &nbsp;充 值&nbsp; </button>&nbsp;
								<button class="btn btn-success f14" onclick="toFunds('out')"> <i class="fa fa-sign-out f12"></i> &nbsp;提现&nbsp; </button>&nbsp;
								<button class="btn btn-warning f14" onclick="toBank()" > <i class="fa fa-bank f12"></i> &nbsp;我的银行&nbsp;</button>&nbsp;
							</div>
					  </div>
				  </div>
			  </div>
		 	</div>
		</div>

		<!-- 消息通知 -->
		<div class="box box-solid" style="background-color: #ffffeb;">
			<div class="box-body">
				<div class="col-lg-12">
					<div class="user_tzgg" style="height:50px;">
						<i class="fa fa-bell col-lg-1"></i>
						<div id="info_div" style="white-space:nowrap;margin-left: -40px;overflow: hidden; display: block;" class="col-lg-11">
			         	<span id="info"></span>
						</div>
					</div>
				</div>
			</div>
		</div>

	  	<!-- 我的持仓 -->
	  	<div class="box box-solid">
			<div class="box-body">
				<div class="col-lg-12">
					<div class="right_box">
						<!-- 待办任务title start -->
						<h4 class="user_title">
							<P>
								<i class="fa fa-hourglass"></i> 我的持仓  <span class="f12"></span>
							</P>
						</h4>
						<!-- 待办任务title end --	>
						<form action="" id="searchFormId" name="searchFormId">
							<input type="hidden" name="doCode" value="dymicSql"/>
							<input type="hidden" name="pageName" value="trsGoods-list"/>
							<input type="hidden" name="formName" value="searchForm"/>
							<input type="hidden" name="trsGoods.userEname" value="${loginUser.userEname}"/>
							<input type="hidden" name="orderBy"  value="trsGoods.create_time desc" />
						</form>
						<!-- 待办任务list start -->
						<table class="table table-hover user_table">
							<thead>
							<tr>
								<th>序号</th>
								<th class="text_c">商品代码</th>
								<th class="text_c">商品名称</th>
								<th class="text_c">总数量</th>
								<th class="text_c">可用数量</th>
								<th class="text_c">冻结数量</th>
							</tr>
							</thead>
							<tbody id="myDaiBanDiv_body">
							</tbody>
						</table>
					</div>
				</div>
			</div>
	  </div>
  </div>
<!-- </div> -->
 <!-- main end-->

<!-- 2开通钱包 -->
<div id="fus_div1_fundsOpen" style="display:none;">
<form id="formFundsOpen" name="myForm" class="regdivbox">
	<input type="hidden" name="userEname" value="${loginUser.userEname}"/>
	<input type="hidden" name="userCname" value="${loginUser.userCname}"/>
	<!-- 	证件类型：<input type="radio" name="certType" checked/> 组织机构代码<br/>
	           证件号码：<input type="text" name="certCode"/><br/>
	            手机号：<input type="text" name="mobile"/><br/>
	            联系人：<input type="text" name="contactuser"/><br/>
	            联系地址：<input type="text" name="contactAddress"/><br/>
	             -->
	<table class="tab_info">
		<tr>
  		<th colspan="2" style="text-align: center;" >
   		为了保证您的资金安全，请设置您的资金账户口令
  		</th>
		</tr>
		<tr>
  		<th>账号信息：</th>
  		<td><span style="color:red;"> ${loginUser.userEname}</span></td>
		</tr>
		<tr>
  		<th>输入口令：</th>
  		<td><input id="fundPas" type="password" size="8" maxlength="6" name="fundPas" style="width:150px;"/>
  		</td>
		</tr>
		<tr>
  		<th>再输一遍：</th>
  		<td><input id="fundPas1" type="password" size="8" maxlength="6" name="fundPas1" style="width:150px;"/>
  		</td>
		</tr>
		<tr>
 		<td colspan="2" align="center">
 			<a href="javascript:void(0);" onclick="subOpenFunds('${loginUser.userPass}'),addNotice();" class="btn btn-success f14">提交信息</a>
 		</td>
		</tr>
	 </table>
	</form>
 </div>
 
 <!-- 消息推送NoticeForm开始 -->
<form class="form-horizontal" role="form" id="addForm">
<input type="hidden" name="trpNotice.delStatus" value="F">
<input type="hidden" name="trpNotice.noticeId" id="noticeId" value="">
<input type="hidden" name="trpNotice.createUser" id="createUser" value="">
<input type="hidden" name="trpNotice.createTime" id="createTime" value="">
<input type="hidden" name="trpNotice.bussCode" id="bussCode" value="">
<input type="hidden" name="trpNotice.bussRemark" id="bussRemark" value="">
<input type="hidden" name="trpNotice.sendCount" id="sendCount" value="">
<input type="hidden" name="trpNotice.bussId" id="bussId" value="">
<input type="hidden" name="trpNotice.bussMethodName" id="bussMethodName" value="">
<input type="hidden" name="trpNotice.bussTableName" id="bussTableName" value="">
<input type="hidden" name="trpNotice.lastTime" id="lastTime" value="">
<input type="hidden" name="trpNotice.delStatus" id="delStatus" value="">
<input type="hidden" id="formToken" name="formToken" >
<input type="hidden" id="noticeTitle" name="trpNotice.noticeTitle" value="项目信息审核"/>
<input type="hidden" id="noticeContent" name="trpNotice.noticeContent" value=""/>
<input type="hidden" id="sendCode" name="trpNotice.sendCode"/><!-- 接收人 -->
<input type="hidden" id="typeName" name="trpNotice.typeName" value="mail"/><!-- 消息类型，站内信 -->
<input type="hidden" id="noticeStatus" name="trpNotice.noticeStatus" value="1" /><!-- 发送状态：未发送 -->
</form>
<!-- 消息推送NoticeForm结束 -->
 
<!-- 3登录钱包 -->
 <div id="fus_div2_fundsLogin" style="display:none;" class="col-lg-11">
 	<form id="fundsLoginForm" name="fundsLoginForm" class="regdivbox">
 	<dl>
  	<dt>请输入您的资金账户口令：<br/><input id="fundLoginPas" type="password" size="8" maxlength="6" name="pass"/></dt>
  	<dd><a href="javascript:void(0);" onclick="subLoginFunds()" class="btn btn-warning f14"> 登 录 </a></dd>
 	</dl>
 	</form>
 </div>
 </div>
 <script type="text/template" id="myDaiBanDiv_template">
			<? for ( var i = 0; i < rows.length; i++) {?>
				<tr>
					<td class="text_c"><?=(pageObj.currentPage-1)*10+(i+1)?></td>
					<td class="text_c"><?=strUtil.doNull(rows[i].proNo,'')?></td>
					<td class="text_l"><?=strUtil.subStr(rows[i].proName,'7')?></td>
					<td class="text_r"><?=strUtil.doNull(rows[i].totalNum,'')?></td>
					<td class="text_r"><?=strUtil.doNull(rows[i].useNum,'')?></td>
					<td class="text_r"><?=strUtil.doNull(rows[i].forzenNum,'')?></td>
				</tr>
   			<?}?>  	
</script>
<div id="div_layer_window" class="popbox">
	<dl>
	  <dt id="view_noticeTitle" style="padding:0 10px;text-align:left;background:#f5f5f5;font-weight:bold;"></dt>
	  <dd id="view_noticeContent" style="padding:0 20px;text-align:left;"></dd>
	</dl>
</div> 
   <!-- foot start -->
  <%@include file="/common/sale/foot-user.jsp" %>
  <!-- foot start -->
</body>
</html>
<script>
	var clickMenu = 'index';
	var page_web = '${page_web}';
	$(function(){
		
  		getMyFunds();
		
		getMyFudsBalance();
		
		getTableData();
		
		getNoticeInfo();
	});
	
	function toFunds(obj){
		//showLoginFundsWin();
		window.location.href="${page_web}/funds/my-funds?direction="+obj;
	}
	function toBank(){
		window.location.href="${page_web}/bank/bank-account";
	}
	//获取我的钱包信息
  	function getMyFunds(){
		if("T"=="${fundsLogin}"){
			$("#funds_2").show();
		}else{
			indexCheckMyFundsV2()
		}
	}
	
	//查询我的资金余额
	function getMyFudsBalance(){
		var index_load = layer.load(1, {shade: false});
		$.ajax({
			type:'get',
			url: common_list_url+'?doCode=F004',
			async: false,
			data: {f:new Date().getTime()},
			dataType:'json',
			success:function(result)	{
				var flag = result.flag;
				layer.close(index_load);
			  	if("T"==flag){
			  		var obj = result.msg;
			  		console.log(obj);
			  		$("#fundsAmtTotal").text(fmoney(obj.amtTotal*1/100));
			  		$("#fundsM1").text(fmoney(obj.m1*1/100));
			  		$("#fundsM2").text(fmoney(obj.m2*1/100));
			  	}
			}
		});
	}
	
	function getTableData(){
		deleteAllRow('myDaiBanDiv_body');
		var searchFormId="searchFormId";
		$.ajax({
			   type:'get',
			   url:common_list_url,
			   data:$("#"+searchFormId).serialize()+getCurrentPage(common_list_url+"?"+$("#"+searchFormId).serialize(),8),
			   dataType:'json',
			   success: function(myData){
				    console.log(myData);
				    var data = baidu.template('myDaiBanDiv_template',eval(myData));  
					$("#myDaiBanDiv_body").html(data);
			   }
			});	
	}
function getNoticeInfo(){
	var userEname = '${loginUser.userEname}';
	$.ajax({
		url:common_list_url+"?doCode=dymicSql&modelTypes=s_trpNotice&trpNotice.typeName=F&trpNotice.sendCode="+userEname,
		type:'get',
		dataType:'json',
		success:function(myData){
			if(myData.total>0){
				var line = "";
				$("#info").html("");
				var window_name = "div_layer_window";
				$.each(myData.rows,function(n,k){
					var noticeContent = k.noticeContent;
					if(null!=noticeContent&&noticeContent.length>10){
						noticeContent=noticeContent.substring(0,6)+"...";
					}
					if(null==noticeContent){
						noticeContent = "----";
					}
					line+="<span style='width:300px;display:inline-block;' onclick='openDiv(\""+window_name+"\",\""+k.noticeId+"\")' >"+k.createTime+":"+noticeContent+"</span>";
				});
				$("#info").html(line);
				setInterval(scroll,5000);
			}else{
				$("#info").html("<span style='display:inline-block;'>暂无消息</span>");
			}
		}
	});
}
 function scroll(){
	 var f = document.getElementById("info").childNodes.item(0).offsetWidth;
	 $("#info").animate({"margin-left":"-"+f+"px"},10000,function(){
	   $("#info span:eq(0)").appendTo($("#info"))
	   $("#info").css({"margin-left":0})
	 })
 }
 function openDiv(divID,noticeId) {
	 	var result = $.platform.ajax({url:'${ctx}/doFM.action?doCode=Mview',data:{noticeId:noticeId},dataType:'json'});
	 	if(result){
	 	       $("#view_noticeTitle").html(result.noticeTitle);
				   $("#view_noticeContent").html(result.noticeContent);
				   $("#"+result.noticeId).html("已读");
				  layer.open({
				    type: 1,
				    title: '查看消息',
				    offset: '120px',
				    closeBtn: 1,
				    area: ['500px','400px'],
				    shadeClose: true,
				    content: $('#div_layer_window')
				 });
				  $.ajax({
					  url:common_submit_url,
					  type:'post',
					  data:{"doCode":"dymicSql","modelTypes":"u_trpNotice","trpNotice.w_noticeId":noticeId,"trpNotice.typeName":"T"},
					  dataType:'json',
					  success:function(myData){
						 if(myData.flag=="F"){
							 layer.alert("操作异常")
						 }
					  }
				  })
		     }
		}
</script>
